<?php

class Form{
    public $action;
    public $method;
    public $id;
    public $encrypt;

    function __construct($a, $m, $i, $e = null){
        $this->action = $a;
        $this->method = $m;
        $this->id = $i;
        $this->encrypt = $e;
    }

    public function open_form(){
        echo "<form action=\"".$this->action."\" method=\"".$this->method."\" id=\"".$this->id."\" encrypt=\"".$this->encrypt."\">";
    }

    public function close_form(){
        echo "</form>";
    }

    public function add_input($i, $t, $l, $n){
        echo "<label>".$l."</label><br>";
        echo "<input id=\"".$i."\" placeholder=\"".substr("$l",0,strlen("$l")-1)."\" type=\"".$t."\" name=\"".$n."\"></input><br>";
    }

    public function add_textarea($l, $id, $n, $c,$r){
        echo "<br><label>".$l."</label><br>";
        echo "<textarea id=\"".$id."\" cols=\"".$c."\"  rows=\"".$r."\" name=\"".$n."\"></textarea><br>";
    }

    public function add_button($ty, $name, $t){
        echo "<input name=\"".$name."\" type=\"".$ty."\" value=\"".$t."\"></input>";
    }

    public function add_select_day($nome){
        $settimana = array ("Lu","Ma","Me","Gi","Ve","Sa","Do");
        echo "<label>".$nome."</label><br>";

        echo "<select>";
            foreach($settimana as $i => $v){
                echo "<option value=\"".$i."\">".$v."</option>";
            }
        echo "</select><br>";
    }
    public function add_select_year($nome){
        $anno = date("Y");

        echo "<label>".$nome."</label><br>";
        echo "<select>";
            for($i = 1970; $i<=$anno; $i++){
                echo "<option value=\"".$i."\">".$i."</option>";
            }
        echo "</select>";
    }
}
?>
